package com.mmall.concurrency.example.aqs;


import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.*;

/**
 * <p>Descriptions...
 *
 * @author Diamon.Cheng
 * @date 2019/12/9.
 */
@Slf4j
public class FutureExamples {


    static  class  MyCallable  implements Callable<String>{
    
        @Override
        public String call() throws Exception {
            log.info("do  something  in callable");
            Thread.sleep(5000);
            return "done";
        }
    }
    
    public static void main(String[] args) throws Exception{
    
        ExecutorService  executorService = Executors.newCachedThreadPool();
        Future<String> future =executorService.submit(new  MyCallable());
        log.info("do something in main");
        Thread.sleep(1000);
        String result = future.get();
        log.info("result：{}", result);
    }
}
